﻿@page "/system_asset/function"
@inherits ListOperateTableBase<FunctionDto, Guid, FunctionEdit,SystemAssetResource>
@{

    TableFilter<ApiHttpMethod>[] apiHttpMethodFilters = EnumHelper.EnumToList<ApiHttpMethod>().Select(x => { return new TableFilter<ApiHttpMethod>() { Text = Localizer[EnumHelper.GetEnumDescriptionOrName(x)], Value = x }; }).ToArray();
}
<div>
    <Table @ref="_table"
           TItem="FunctionDto"
           DataSource="@_datas"
           Total="_total"
           OnChange="@OnChange"
           @bind-PageSize="_pageSize"
           @bind-PageIndex="_pageIndex"
           @bind-SelectedRows="_selectedRows"
           Loading="@_tableLoading.Value"
           Context="model"
           Size="@ClientConstant.DefaultTableSize"
           ScrollX="100%"
           PaginationPosition="@ClientConstant.TablePaginationPosition"
           RemoteDataSource
           RowKey="x=>x.Id.ToString()">
        <TitleTemplate>
            <ResourceAuthorize ResourceKey="system_asset_function_refresh">
                <TableSearch TDto="FunctionDto" OnSearch="OnTableSearch" @ref="this._tableSearch" Settings="_tableSearchSettings" CustomLocalizer="Localizer"></TableSearch>
            </ResourceAuthorize>
            <Row>
                <AntDesign.Col Span="8">
                    <ResourceAuthorize ResourceKey="system_asset_function_delete_selected">
                        <Button Type="@ButtonType.Primary" Icon="delete" Danger OnClick="OnClickDeletes" Loading="_deletesBtnLoading">
                            @Localizer[nameof(SharedLocalResource.DeleteSelected)]
                        </Button>
                    </ResourceAuthorize>
                </AntDesign.Col>
                <AntDesign.Col Span="16" Style="text-align:right">
                    <Space>
                        <ResourceAuthorize ResourceKey="system_asset_function_import">
                            <SpaceItem>
                                <Button Type="@ButtonType.Primary" Icon="import" OnClick="OnImportClick">
                                    @Localizer[nameof(SharedLocalResource.Import)]
                                </Button>
                            </SpaceItem>
                        </ResourceAuthorize>
                        <ResourceAuthorize ResourceKey="system_asset_function_export">
                            <SpaceItem>
                                <Button Type="@ButtonType.Primary" Icon="export" OnClick="OnClickExport" Loading="_exportDataLoading">
                                    @Localizer[nameof(SharedLocalResource.Export)]
                                </Button>
                            </SpaceItem>
                        </ResourceAuthorize>
                        @* <ResourceAuthorize ResourceKey="system_asset_function_add">
                            <SpaceItem>
                                <Button Type="@ButtonType.Primary" Icon="plus" OnClick="OnClickAdd">
                                    @Localizer[nameof(SharedLocalResource.Add)]
                                </Button>
                            </SpaceItem>
                        </ResourceAuthorize> *@

                        <ResourceAuthorize ResourceKey="system_asset_function_refresh">
                            <SpaceItem>
                                <Button Type="@ButtonType.Primary" Icon="reload" OnClick="ReLoadTable">
                                    @Localizer[nameof(SharedLocalResource.Refresh)]
                                </Button>
                            </SpaceItem>
                        </ResourceAuthorize>
                        @* <ResourceAuthorize ResourceKey="system_asset_function_download_seed_data">
                        <SpaceItem>
                        <Button Type="@ButtonType.Primary" Icon="download" OnClick="OnClickShowSeedData">
                        @Localizer[nameof(SharedLocalResource.SeedData)]
                        </Button>
                        </SpaceItem>
                        </ResourceAuthorize> *@
                    </Space>
                </AntDesign.Col>
            </Row>

        </TitleTemplate>
        <ColumnDefinitions>
            <Selection Hidden="@_userUnauthorizedResources["system_asset_function_delete_selected"]" Width="50" Fixed="left" />
            <PropertyColumn Property="x=>x.ModuleName" Filterable Width="120" Fixed="left" />
            <PropertyColumn Property="x=>x.Group" Width="150" Filterable>
                <span>@model.Group</span>
            </PropertyColumn>
            <PropertyColumn Property="x=>x.GroupTitle" Width="120" Fixed="left" Filterable>
                <span>@model.GroupTitle</span>
            </PropertyColumn>
            <PropertyColumn Property="x=>x.TagTitles" Width="130" Fixed="left" Filterable>
                <span>@model.TagTitles</span>
            </PropertyColumn>
            
            <PropertyColumn Property="x=>x.Tags" Width="150" Filterable>
                <span>@model.Tags</span>
            </PropertyColumn>
            <PropertyColumn Property="x=>x.Key" Width="200" Filterable />
            <PropertyColumn Property="x=>x.Summary" Width="100" Filterable />
            <PropertyColumn Property="x=>x.Description" Width="200" Filterable />
            <PropertyColumn Property="x=>x.Path" Width="300" Filterable />
            <PropertyColumn Property="x=>x.Method" Width="100" Filters="apiHttpMethodFilters">
                <TagPro Text="@EnumHelper.GetEnumDescription(model.Method)"></TagPro>
            </PropertyColumn>
            <PropertyColumn Property="x=>x.EnableAudit" Width="100" Filterable>
                <ResourceAuthorize ResourceKey="system_asset_function_enable_audit">
                    <Authorized>
                        <Switch @bind-Value="@model.EnableAudit" OnChange="e=>OnChangeEnableAudit(model,e)"></Switch>
                    </Authorized>
                    <NotAuthorized>
                        <TagYesNo Yes="model.EnableAudit"></TagYesNo>
                    </NotAuthorized>
                </ResourceAuthorize>
            </PropertyColumn>
            <PropertyColumn Property="x=>x.IsLocked" Width="100" Filterable>
                <ResourceAuthorize ResourceKey="system_asset_function_lock">
                    <Authorized>
                        <Switch @bind-Value="@model.IsLocked" OnChange="e=>OnChangeIsLocked(model,e)" Loading="_lockBtnLoading[model]"></Switch>
                    </Authorized>
                    <NotAuthorized>
                        <TagYesNo Yes="model.IsLocked"></TagYesNo>
                    </NotAuthorized>
                </ResourceAuthorize>
            </PropertyColumn>
            
            <PropertyColumn Property="x=>x.CreatedTime" Format="@ClientConstant.DateTimeFormat" Sortable Width="150" DefaultSortOrder="@SortDirection.Descending" />
            <ActionColumn Width="150" Fixed="right">
                <Space>
                    <ResourceAuthorize ResourceKey="system_asset_function_edit">
                        <SpaceItem>
                            <Tooltip Title="@Localizer[nameof(SharedLocalResource.Edit)]" ArrowPointAtCenter="true">
                                <Button Icon="edit" Type="@ButtonType.Primary" Size="@ClientConstant.OperationButtonSize" OnClick="()=>OnClickEdit(model.Id)"></Button>
                            </Tooltip>
                        </SpaceItem>
                    </ResourceAuthorize>
                    <ResourceAuthorize ResourceKey="system_asset_function_detail">
                        <SpaceItem>
                            <Tooltip Title="@Localizer[nameof(SharedLocalResource.Detail)]" ArrowPointAtCenter="true">
                                <Button Icon="eye" Type="@ButtonType.Primary" Size="@ClientConstant.OperationButtonSize" OnClick="()=>OnClickDetail(model.Id)"></Button>
                            </Tooltip>
                        </SpaceItem>
                    </ResourceAuthorize>
                    <ResourceAuthorize ResourceKey="system_asset_function_delete">
                        <SpaceItem>
                            <Tooltip Title="@Localizer[nameof(SharedLocalResource.Delete)]" ArrowPointAtCenter="true">
                                <Button Icon="delete" Type="@ButtonType.Primary" Danger OnClick="()=>OnClickDelete(model.Id)"></Button>
                            </Tooltip>
                        </SpaceItem>
                    </ResourceAuthorize>
                </Space>
            </ActionColumn>
        </ColumnDefinitions>
    </Table>
</div>